<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="../lib/react.development.js"></script>
    <script src="../lib/react-dom.development.js"></script>
    <script src="../lib/babel.js"></script>
    <style>
        .box{
            width:200px;
            height:100px;
            background-color: #f2f2f2;
        }
        .btn1{
            color:red;
        }
        .btn2{
            color:blue;
        }
    </style>
</head>
<body>
<div id="example"></div>
<script type="text/jsx">

    //显示区域
    class Clock extends React.Component {
        render() {
            return (
                <div>
                    <h1>Hello, world!</h1>
                    <div className="box">
                        <Greeting type="" />
                    </div>
                </div>
            );
        }
    }

    function Greeting2(props){
        if(props.type == 1){
            return <button onClick={clickEvent}>login</button>
        }else{
            return <button onClick={clickEvent}>logout</button>
        }
    }
    class Greeting extends React.Component {
        constructor(props) {
            super(props);
            this.state = {type:true};
        }
        clickEvent = () => {
            this.setState({
                state:!this.state.type
            })
        };
        render(){
            return (
                <button className={this.props.type ? "btn1" : "btn2"} onClick={this.clickEvent}> {this.props.type ? "login" : "logout"} </button>
            );
        }
    }

    ReactDOM.render(
        <Clock />,
        document.getElementById('example')
    );


</script>
</body>
</html>